//
//  BETextFieldView.m
//  s.
//
//  Created by fanshijian on 2022/8/29.
//  Copyright © 2022 J. All rights reserved.
//

#import "BETextFieldView.h"

@interface BETextFieldView ()

@property (weak, nonatomic) UIView *bgView;
@property (weak, nonatomic) UITextField *tf;

@end

@implementation BETextFieldView

- (UIView *)bgView {
    if (!_bgView) {
        UIView *obj = [UIView new];
        [self addSubview:_bgView = obj];
        [obj mas_makeConstraints:^(MASConstraintMaker *make) {
            kMakeEdge0;
        }];
    }
    return _bgView;
}

- (UITextField *)tf {
    if (!_tf) {
        UITextField *obj = [UITextField new];
        [self.bgView addSubview:_tf = obj];
        [obj mas_makeConstraints:^(MASConstraintMaker *make) {
            kMakeEdge0;
        }];
        obj.textAlignment = NSTextAlignmentLeft;
        obj.font = U_font(14);
        obj.textColor = KLColor(@"#000000");
    }
    return _tf;
}

- (UITextField *)txtField {
    return self.tf;
}

- (void)setFieldInsets:(UIEdgeInsets)fieldInsets {
    _fieldInsets = fieldInsets;
    [self.tf mas_updateConstraints:^(MASConstraintMaker *make) {
        kMakeEdgeV(fieldInsets);
    }];
}

- (void)setBgColor:(UIColor *)bgColor {
    self.bgView.backgroundColor = bgColor;
}

@end
